package uit.comstore.controller;

import java.util.Date;
import java.util.List;

import uit.comstore.model.blo.FaqBLO;
import uit.comstore.model.entity.Faq;

public class FaqAction {
	private FaqBLO faqBLO;
	private Faq faq;
	private List<Faq> faqList;
	private Long id;

	public FaqAction() {
		faqBLO = new FaqBLO();
	}

	public String execute() {
		this.faqList = faqBLO.list();
		return "success";
	}
	public String editFaq(){
		try{
			Faq faq = getFaq();
			faq.setLastModified(new Date());
			faqBLO.update(faq);
		}catch(Exception ex){
			//System.out.println("Cannot add Customer!");
		}
		this.faqList = faqBLO.list();
		return "success";
	}
	
	public String addFaq(){
		try{
			Faq faq = getFaq();
			faq.setStatus(1);
			faq.setDateAdded(new Date());
			faq.setLastModified(new Date());
			faqBLO.add(faq);
		}catch(Exception ex){
			//System.out.println("Cannot add Customer!");
		}
		this.faqList = faqBLO.list();
		return "success";
	}
	
	

	public String deleteFaq() {
		faqBLO.delete(getId());
		return "success";
	}

	public FaqBLO getFaqBLO() {
		return faqBLO;
	}

	public void setFaqBLO(FaqBLO faqBLO) {
		this.faqBLO = faqBLO;
	}

	public Faq getFaq() {
		return faq;
	}

	public void setFaq(Faq faq) {
		this.faq = faq;
	}

	public List<Faq> getFaqList() {
		return faqList;
	}

	public void setFaqList(List<Faq> faqList) {
		this.faqList = faqList;
	}

	public Long getId() {
		return id;
	}

	public void setId(Long id) {
		this.id = id;
	}
	//Show FAQ on front end
	public String show(){
		return "success";
	}
	

}
